
Product
A New Overview in our Dashboard
We redesigned Socket's first logged-in page to display rich and insightful visualizations about your repositories protected against supply chain threats.
timeago-react
Advanced tools
timeago-react is a simple(only 1kb) react component used to format date with `*** time ago` statement. eg: '3 hours ago'.
timeago-react is a simple react component used to format date with
*** time ago
statement. eg: '3 hours ago'.
The component based on timeago.js which is a simple javascript module.
3 hour ago
, the interval will an hour (3600 * 1000 ms).npm install timeago-react
import * as React from 'react';
import TimeAgo from 'timeago-react'; // var TimeAgo = require('timeago-react');
<TimeAgo
datetime={'2016-08-08 08:08:08'}
locale='zh_CN'
/>
datetime
(required, string / Date / timestamp)The datetime to be formatted. can be datetime string
, Date instance
, or timestamp
.
live
(optional, boolean)Live render, default is true
.
className
(optional, string)The class
of span. you can setting the css style of span by class name.
opts.relativeDate
(optional, string / Date / timestamp)The datetime to be calculated interval relative to.
opts.minInterval
(optional, number in seconds)The min interval in seconds to update the ** time ago string
locale
(optional, string)The locale
language of statement, default is en
. All supported locales here. If you want to use locale which is not zh_CN
/ en
, you should import the locale before use it. As below:
import * as React from 'react';
import TimeAgo from 'timeago-react';
import * as timeago from 'timeago.js';
// import it first.
import vi from 'timeago.js/lib/lang/vi';
// register it.
timeago.register('vi', vi);
// then use it.
<TimeAgo
datetime={'2016-08-08 08:08:08'}
locale='vi'
/>
style
(optional, object)The style
object to applied to the root element.
Props not documented above are applied to the root element.
MIT
FAQs
timeago-react is a simple(only 1kb) react component used to format date with `*** time ago` statement. eg: '3 hours ago'.
We found that timeago-react demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 0 open source maintainers collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Product
We redesigned Socket's first logged-in page to display rich and insightful visualizations about your repositories protected against supply chain threats.
Product
Automatically fix and test dependency updates with socket fix—a new CLI tool that turns CVE alerts into safe, automated upgrades.
Security News
CISA denies CVE funding issues amid backlash over a new CVE foundation formed by board members, raising concerns about transparency and program governance.